app
.controller('formSelfCtrl', ['$scope', '$http', FormSelfController]);
function FormSelfController($scope, $http){
	$scope.changeValueMap = function(field) {
		console.log('----field-----', field);
		var basicSalary = parseFloat($scope.valueMap['basicSalary']); // 基本底薪
		var positionSalary = parseFloat($scope.valueMap['positionSalary']); // 岗位薪资
		var perbasedSalary = parseFloat($scope.valueMap['perbasedSalary']); // 绩效薪资
		var transSubsidy = parseFloat($scope.valueMap['transSubsidy']); // 交通补贴
		var cateringSubsidy = parseFloat($scope.valueMap['cateringSubsidy']); // 餐饮补贴
		var jobPromotion = parseFloat($scope.valueMap['jobPromotion']); // 岗位提奖/月
		var quarterlyBonus = parseFloat($scope.valueMap['quarterlyBonus']); // 季度提奖
		var annualBonus = parseFloat($scope.valueMap['annualBonus']); // 年终奖标准

		if((basicSalary || basicSalary == 0)
			&& (positionSalary || positionSalary == 0)
			&& (perbasedSalary || perbasedSalary == 0)
			&& (transSubsidy || transSubsidy == 0)
			&& (cateringSubsidy || cateringSubsidy == 0)
			&& (jobPromotion || jobPromotion == 0)
			&& (quarterlyBonus || quarterlyBonus == 0)
			&& (annualBonus || annualBonus == 0)) {
			// 发薪标准 = 基本底薪/月+岗位薪资/月+绩效薪资/月+交通补贴/月+餐饮补贴/月+岗位提奖/月
			var salaryStandard = basicSalary + positionSalary + perbasedSalary + transSubsidy + cateringSubsidy + jobPromotion ;
			$scope.valueMap['salaryStandard'] = salaryStandard
			
			// 定薪标准 = 发薪标准/月+季度提奖/月
			var fixsalaryStandard = salaryStandard + quarterlyBonus;
			$scope.valueMap['fixsalaryStandard'] = fixsalaryStandard;
			
			// 固定薪资比例 = （基本底薪/月+岗位薪资/月）/发薪标准/月
			var fixedSalaryRatio = ((basicSalary + positionSalary) / salaryStandard * 100).toFixed(2);

			if(salaryStandard == 0){
				fixedSalaryRatio =0;
			}
			$scope.valueMap['fixedSalaryRatio'] = fixedSalaryRatio;
			// 绩效薪资比例 = （绩效薪资/月+交通补贴/月+餐饮补贴/月）/发薪标准/月
			var performanceRatio =((perbasedSalary + transSubsidy + cateringSubsidy) / salaryStandard * 100).toFixed(2);
			if(salaryStandard == 0){
				performanceRatio =0;
			}
			$scope.valueMap['performanceRatio'] = performanceRatio;
		}
	}
}

